<!DOCTYPE html>  
<html>  
  <head>  
    <title>Polymorphism</title>  
  </head>
  <body>  
    <script type="text/javascript">
      class Animal {
        animalSound() {
          document.write("The animal makes a sound<br>");
        }
      }

      class Pig extends Animal {
        animalSound() {
          document.write("The pig says: wee wee<br>");
        }
      }

      class Dog extends Animal {
        animalSound() {
          document.write("The dog says: bow wow<br>");
        }
      }
      
      var myAnimal = new Animal();  // Create a Animal object
      var myPig = new Pig();  // Create a Pig object
      var myDog = new Dog();  // Create a Dog object
      myAnimal.animalSound();
      myPig.animalSound();
      myDog.animalSound();
    </script> 
  </body>  
</html>